Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gslux 755 location info #175

Merged
merged 52 commits into from
Dec 17, 2024
Merged

Gslux 755 location info #175

merged 52 commits into from
Dec 17, 2024

Conversation

mki-c2c
Copy link
Contributor

@mki-c2c mki-c2c commented Nov 22, 2024

JIRA issue

https://jira.camptocamp.com/browse/GSLUX-XXX

Description

(details of the change, additional tests that have been done, reference to the issue for tracking, etc)

Screenshots

(only if the final render is different)

Copy link
Contributor

GitHub Pages links: * Luxembourg-geoportail: https://geoportail-luxembourg.github.io/luxembourg-geoportail/GSLUX-755-location_info/

@mki-c2c mki-c2c force-pushed the GSLUX-755-location_info branch from 16b4f94 to 129ffb0 Compare November 27, 2024 13:50
@@ -31,7 +31,7 @@ describe('Footer bar', () => {
cy.get('[data-cy="infoOpenClose"]').find('button').click()
cy.get('[data-cy="infoPanel"]').should('exist')
cy.get('button[data-cy="drawButton"]').click()
cy.get('[data-cy="infoPanel"]').should('not.exist')
cy.get('[data-cy="infoPanel"]').should('be.hidden')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why hiding the panel with css instead of removing it from the dom?

</ul>
</div>
<template v-if="map">
<div v-show="locationInfo" class="absolute">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason why using v-if l.37 and v-show l.38? could this be done using only one if? (and use v-else l.43)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v-show is needed so that the streetview component remains persistant, so that the dom reference in google code remains valid
v-if removes thecomponent from the dom

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok understood, I hope this won't break the v3 panel because I remember facing some issues when the v3 was just hidden.But maybe it won't be the case for your Streetview panel.


const map = useMap().getOlMap()

const shortUrl = ref()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be great to add some typing here, I don't even understand how this can pass the linter...

clickCoordinateLuref.value = info.clickCoordinateLuref
formatted_coordinates.value = info.formatted_coordinates
elevation.value = await getElevation(info.clickCoordinateLuref)
address.value = await getNearestAddress(info.clickCoordinateLuref)
Copy link
Contributor

@AlitaBernachot AlitaBernachot Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are doing 3 await sequentially, this means the user is going to wait a bit more at each request. Please use parallele loading instead (eg. Promise.allSettled).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, good idea, the awaits came together after refactoring,and I did not notice the possibility to regroup

const elevation = ref()
const address = ref()
const clickCoordinateLuref = ref()
const formatted_coordinates = ref({})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do use camel case in our code since the beginning of the project.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep,
do you think it's possible to enforce camelCase in the linter if it is a project standard?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, "camelcase": "on" (I guess, did not test)

https://eslint.org/docs/latest/rules/camelcase#rule-details


const isRapportForageVirtuelAvailable = computed(() => {
const userRole = 'ACT'
return userRole === 'ACT'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment here? because I don't understand the utility of this (maybe because the PR isn't finished yet?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, still a stub (I should have marked it)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI if you need user's role it is available in the auth service.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or user-manager store

const getLidarUrl = () => 'bla'
const cyclomediaUrl = computed(() =>
clickCoordinateLuref.value
? `http://streetsmart.cyclomedia.com/streetsmart?q=${clickCoordinateLuref.value[0]};${clickCoordinateLuref.value[1]}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move http://streetsmart.cyclomedia.com/streetsmart to a const in .env

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

const isCyclomediaAvailable = computed(() => true)
const isImagesObliquesAvailable = computed(() => true)

const getLidarUrl = () => 'bla'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this won't stay as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope

const addRoutePoint = () => '// TODO: add point to route'

const open = ref(true)
const { isStreetviewActive } = storeToRefs(useInfoStore())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useInfoStore() is also called l. 18, instead declare a new const infoStore = useInfoStore() and use this new const.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I'll do a one-line destructioning


const open = ref(true)
const { isStreetviewActive } = storeToRefs(useInfoStore())
const toggleStreetview = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const toggleStreetview = () => {
function toggleStreetview () {

Any reason why this is declared as a const?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any difference ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


function downloadRapportForageVirtuel() {
downloadingRepport.value = true
setTimeout(() => (downloadingRepport.value = false), 2000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a comment here? it looks like it is unfinished

<template>
<div class="flex flex-row">
<div class="grow-[2] flex flex-col content-end">
<div class="grow"></div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't add empty dom node just for display.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need a spacer for flex

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't add empty dom node just for display.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

justify-end works also

<h3 class="text-3xl text-white">
{{ t('Short Url', { ns: 'client' }) }}
</h3>
<input
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input should have a name or id attribute to be html valid (and accessibility compliance).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tricky one, thanks

added: aria-labelledby="short_url_title"

no name needed since input is not part of a form

<td>{{ coords }}</td>
</tr>
<tr>
<th style="text-align: left">{{ t('Elevation') }}</th>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use tailwind class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to remove (handled by CSS)

<td>{{ elevation }}</td>
</tr>
<tr>
<th style="text-align: left">{{ t('Adresse la plus proche') }}</th>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use tailwind class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to remove (handled by CSS)

<td>{{ address?.formattedAddress }}</td>
</tr>
<tr>
<th style="text-align: left">{{ t('Distance approximative') }}</th>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use tailwind class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to remove (handled by CSS)

<img class="mx-5 mt-5" v-if="qrUrl" :src="qrUrl" />
</div>
<div>
<div class="mt-5">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like you can get rid of this dev and add the "mt-5" class to the h3 below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

</table>
</div>
<div>
<div v-if="isRapportForageVirtuelAvailable">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look like this div is not useful and the condition can be attached to the button below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removesd

<a
v-if="isInBoxOfLidar"
class="lux-btn whitespace-nowrap"
:href="getLidarUrl()"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this one getter whereas the others are refs?

class="h-[500px]"
v-show="isStreetviewActive && !noDataAtLocation"
>
Streetview Container
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a title? any translation for that?

Streetview Container
</div>
<div
class="grid before:content-streetview before:col-start-1 before:row-start-1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a grid? you only display a text message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -93,7 +93,7 @@ watch(infoOpen, infoOpen => {
</div>

<!-- Info panel -->
<div v-if="infoOpen" class="w-full md:w-80 bg-secondary z-10">
<div v-show="infoOpen" class="w-full md:w-80 bg-secondary z-10">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as first comment above, any reason why you are hiding the panel instead of remove it from the dom like the others?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

streetview needs to be persistent

if (doHide) {
infoFeatureLayer.getSource()?.clear()
} else {
if (locationInfo.value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use else if

if (location && !hidePointer.value) {
infoOpen.value = true
const feature = new Feature(new Point(location))
infoFeatureLayer.getSource()?.addFeature(feature)
Copy link
Contributor

@AlitaBernachot AlitaBernachot Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This watcher is very similar to the previous one, maybe they can be combined into one.
Or at least a bit of refactor, move

const feature = new Feature(new Point(location))
infoFeatureLayer.getSource()?.addFeature(feature)

into a new function eg. createNewPoint()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, thanks

return map.getEventCoordinate(event.originalEvent)
}

const handleClick = function (event: MapBrowserEvent<PointerEvent>) {
Copy link
Contributor

@AlitaBernachot AlitaBernachot Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why declaring function 3 different ways in this file? (getClickCoordinate, handleClick, setInfoStyle)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typescript's fault ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

harmonized

if (event.originalEvent.button === 2) {
// if right mouse click
locationInfo.value = getClickCoordinate(event)
} else if (event.originalEvent.pointerType == 'touch') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ===

}
}

listen(map, 'pointerup', (event: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use any, you have found the right typing below event as MapBrowserEvent<PointerEvent>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a MapBrowserEvent<MouseEvent>, unfortunaltely incompatible

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incompatible with what? don't use any, please. You can remove it, TS will consider it as a BaseEvent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I had not tried simply removing it :-(

listen(map, 'pointerup', (event: any) => {
if (
startPixel &&
(event as MapBrowserEvent<PointerEvent>).originalEvent.button === 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the typing event as MapBrowserEvent<PointerEvent> up l. 85 to replace the any

Copy link
Contributor Author

@mki-c2c mki-c2c Dec 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not work, above is MapBrowserEvent<MouseEvent> so it needs to be cast to any however

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incompatible with what? don't use any, please. You can remove it, TS will consider it as a BaseEvent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, just removing it works, thanks!

(I had tried all sort of combinations, BaseEvent was not accepted, the signature wanted Event | BaseEvent, but I could not figure out where to find "Event" )

@mki-c2c mki-c2c force-pushed the GSLUX-755-location_info branch from 11b0349 to e5ec30d Compare December 12, 2024 11:12
@mki-c2c
Copy link
Contributor Author

mki-c2c commented Dec 13, 2024

hello @tkohr
I did the rebase wrt the feature info branch. could you please check the latest commits if you think this is OK with your code ?

I would like to do some more harmonization, what do you think of it ?:

  • move locationInfo and streetview composables into composables/info
  • use only one info store with both location and feature states => rename info store to location-info store
  • move locationInfo e2e test into cypress/e2e/info

Comment on lines 29 to 31
onUnmounted(() => {
clearContent()
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we really need the v-show above this component, we could get rid of the onUnmounted I guess ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right.

I could not set up the correct link to street view without the component being persistent

@tkohr
Copy link
Contributor

tkohr commented Dec 13, 2024

hello @tkohr I did the rebase wrt the feature info branch. could you please check the latest commits if you think this is OK with your code ?

Thanks for the rebase @mki-c2c ! Looks nice to see the right click and left click work together. Didn't notice any issues with the feature info part.

I would like to do some more harmonization, what do you think of it ?:

* [ ]  move locationInfo and streetview composables into composables/info

Good idea!

* [ ]  use only one info store with both location and feature states

What do you think of creating an info folder within the stores, renaming the info.store to location-info.store and moving location-info.store and feature-info.store to the same folder? I feel like keeping both separated in different stores, keeps things clearer.

* [ ]  move locationInfo e2e test into cypress/e2e/info

Good idea!

@mki-c2c mki-c2c merged commit aea4b4b into main Dec 17, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants